<?php
	//digunakan untuk kelas untuk permintaan yang tidak biasa
	class BIRD_MODEL extends CI_Model{
		var $temp =0;
		/**
		*	@param Pigeon, 
		*	I:	intid_week,
		*	O:	query->result
		* 	Desc: untuk melihat laporan totalomset per-week dari seluruh cabang
		*/
		function Pigeon($week){
		
			/*
			$query = $this->db->query('SELECT *,
				(select sum(n.inttotal_omset) totalomset from nota n where n.intid_cabang = c.intid_cabang and n.intid_week = "$week") totalomset 
				from cabang c
				where c.intid_cabang !="" and c.intid_cabang != 1');
			return $query->result();
			/*
			select sum(n.inttotal_omset) from nota n where n.intid_cabang = c.intid_cabang  
			*/
			$query = $this->db->query('SELECT strnama_cabang,
				(select sum(n.inttotal_omset)as totalomset from nota n where n.intid_cabang = c.intid_cabang and n.intid_week = "'.$week.'") totalomset 
				from cabang c
				where c.intid_cabang !="" and c.intid_cabang != 1');
			return $query->result();
			
		}
		/**
		*	@param WoodPecker_Melanerpes, 
		*	I:	intid_week,
		*	O:	query->result
		* 	Desc: untuk melihat laporan semua omset per-week dari seluruh cabang
		*/
		/*
		function WoodPecker_Melanerpes($week){
		//////isinya sma dengan sales mingguan tapi semua cabang dimunculin.
		$this->temp = 'select
				(SELECT SUM(nota.inttotal_omset) FROM nota
				WHERE nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'") inttotal_omset,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.is_dp != 1 
				and nota.is_arisan != 1 
				and nota.intid_jpenjualan = 1 ) intomset10Reguler,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.is_dp != 1 
				and nota.is_arisan != 1 
				and nota.intid_jpenjualan = 1)intomset20Reguler,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.is_arisan = 1 
				and nota.intid_jpenjualan = 1 ) intomset10Arisan,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.is_arisan = 1 
				and nota.intid_jpenjualan = 1)intomset20Arisan,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'" 
				and nota.intid_jpenjualan = 2 ) intomset10ChallHut,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.intid_jpenjualan = 2 )intomset20ChallHut,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'" 
				and nota.intid_jpenjualan = 3 ) intomset10Challange,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.intid_jpenjualan = 3 )intomset20Challange,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'" 
				and nota.intid_jpenjualan = 4 ) intomset10TradeIn,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.intid_jpenjualan = 4 )intomset20TradeIn,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'" 
				and nota.intid_jpenjualan = 5 ) intomset101free1net,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.intid_jpenjualan = 5 )intomset201free1net,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'" 
				and nota.intid_jpenjualan = 6 ) intomset101free110prs,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.intid_jpenjualan = 6 )intomset201free110prs,				
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang
				WHERE nota.intid_week = "'.$week.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_cabang != 1
				AND nota.intid_jpenjualan = 7) omsetnetto, 
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang
				WHERE nota.intid_week = "'.$week.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_cabang != 1
				AND nota.intid_jpenjualan = 11) omsetspecialprice,
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang
				WHERE nota.intid_week = "'.$week.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_jpenjualan = 12) omsetpoint,
				(SELECT sum(nota.inttotal_bayar) 
				FROM nota
				WHERE nota.intid_week = "'.$week.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_jpenjualan = 10) omsetsk,
				(select sum(nota_detail.intquantity*nota_detail.intharga) 
				from nota, nota_detail, barang 
				where nota.intid_nota = nota_detail.intid_nota
				and nota_detail.intid_barang = barang.intid_barang
				and nota.intid_week = "'.$week.'"
				and nota.intid_cabang = c.intid_cabang
				and nota.is_arisan = 0
				and nota.is_dp = 0
				and barang.intid_jbarang=5) omsetlg,
				(select sum(nota_detail.intquantity*nota_detail.intharga) 
				from nota, nota_detail, barang 
				where nota.intid_nota = nota_detail.intid_nota
				and nota_detail.intid_barang = barang.intid_barang
				and nota.intid_week = "'.$week.'"
				and nota.intid_cabang = c.intid_cabang
				and barang.intid_jbarang=6
				and nota.is_arisan = 0
				and nota.is_dp = 0) omsetll,
				(select sum(inttotal_bayar) from nota where 
				nota.intid_cabang = c.intid_cabang
				and nota.intid_week = "'.$week.'") inttotal_bayar,
				(select sum(intpv) from nota where 
				nota.intid_cabang = c.intid_cabang
				and nota.intid_week = "'.$week.'") intpv,
			c.strnama_cabang 
			from cabang c';
		$query = $this->db->query($this->temp);
	return $query->result();
		}
		*/
	/**
		*	@param WoodPecker_Sphyrapicus, 
		*	I:	intid_week,
		*	O:	query->result
		* 	Desc: untuk melihat laporan semua omset per-bulan dari seluruh cabang
		*/
		/*
		function WoodPecker_Sphyrapicus($month){
		//////isinya sma dengan sales Bulanan tapi semua cabang dimunculin.
		$this->temp = 'select
				(SELECT SUM(nota.inttotal_omset) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'") inttotal_omset,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.is_arisan != 1 
				and nota.intid_jpenjualan = 1 ) intomset10Reguler,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.is_arisan != 1 
				and nota.intid_jpenjualan = 1)intomset20Reguler,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_arisan = 1 
				and nota.intid_jpenjualan = 1 ) intomset10Arisan,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_arisan = 1 
				and nota.intid_jpenjualan = 1)intomset20Arisan,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 2 ) intomset10ChallHut,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 2 )intomset20ChallHut,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 3 ) intomset10Challange,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 3 )intomset20Challange,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 4 ) intomset10TradeIn,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 4 )intomset20TradeIn,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'" 
				and nota.intid_jpenjualan = 5 ) intomset101free1net,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 5 )intomset201free1net,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 6 ) intomset101free110prs,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 6 )intomset201free110prs,				
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_cabang != 1
				AND nota.intid_jpenjualan = 7) omsetnetto, 
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_cabang != 1
				AND nota.intid_jpenjualan = 11) omsetspecialprice,
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_jpenjualan = 12) omsetpoint,
				(SELECT sum(nota.inttotal_bayar) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_jpenjualan = 10) omsetsk,
				(select sum(nota_detail.intquantity*nota_detail.intharga) 
				from nota, nota_detail, barang, week 
				where nota.intid_nota = nota_detail.intid_nota
				and nota_detail.intid_barang = barang.intid_barang
				and week.intbulan = "'.$month.'"
				and nota.intid_week = week.intid_week
				and nota.intid_cabang = c.intid_cabang
				and nota.is_arisan = 0
				and nota.is_dp = 0
				and barang.intid_jbarang=5) omsetlg,
				(select sum(nota_detail.intquantity*nota_detail.intharga) 
				from nota, nota_detail, barang, week 
				where nota.intid_nota = nota_detail.intid_nota
				and nota_detail.intid_barang = barang.intid_barang
				and week.intbulan = "'.$month.'"
				and nota.intid_week = week.intid_week
				and nota.intid_cabang = c.intid_cabang
				and barang.intid_jbarang=6
				and nota.is_arisan = 0
				and nota.is_dp = 0) omsetll,
				(select sum(inttotal_bayar) from nota inner join week on nota.intid_week = week.intid_week
				where 
				nota.intid_cabang = c.intid_cabang
				and week.intbulan = "'.$month.'") inttotal_bayar,
				(select sum(intpv) from nota inner join week on nota.intid_week = week.intid_week where 
				nota.intid_cabang = c.intid_cabang
				and week.intbulan = "'.$month.'") intpv,
			c.strnama_cabang 
			from cabang c';
		$query = $this->db->query($this->temp);
	return $query->result();
		}
		*/
		/**
		*	@param Grey_Headed_Woodpecker
		*	I:	intid_week,
		*	O:	query->result
		* 	Desc: untuk melihat laporan semua omset per-week dari seluruh cabang
		*/
		function Grey_Headed_Woodpecker($week){
		//////isinya sma dengan sales mingguan tapi semua cabang dimunculin.
		$this->temp = 'select
				(SELECT SUM(nota.inttotal_omset) FROM nota
				WHERE nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'") inttotal_omset,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.is_dp != 1 
				and nota.is_arisan != 1 
				and nota.intid_jpenjualan = 1 ) intomset10Reguler,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.is_dp != 1 
				and nota.is_arisan != 1 
				and nota.intid_jpenjualan = 1)intomset20Reguler,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.is_arisan = 1 
				and nota.intid_jpenjualan = 1 ) intomset10Arisan,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.is_arisan = 1 
				and nota.intid_jpenjualan = 1)intomset20Arisan,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'" 
				and nota.is_dp = 0
				and nota.intid_jpenjualan = 2 ) intomset10ChallHut,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.is_dp = 0
				and nota.intid_jpenjualan = 2 )intomset20ChallHut,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'" 
				and nota.is_dp = 0
				and nota.intid_jpenjualan = 3 ) intomset10Challange,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.is_dp = 0
				and nota.intid_jpenjualan = 3 )intomset20Challange,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'" 
				and nota.is_dp = 0
				and nota.intid_jpenjualan = 4 ) intomset10TradeIn,
				(SELECT SUM(nota.inttotal_bayar) FROM nota
				WHERE  nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.intomset20 = 0
				and nota.is_dp = 0
				and nota.intid_jpenjualan = 5 ) intomset101free1net,
				(SELECT SUM(nota.intomset10) FROM nota
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'" 
				and nota.is_dp = 0
				and nota.intid_jpenjualan = 6 ) intomset101free110prs,
				(SELECT SUM(nota.intomset20) FROM nota
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.intid_week = "'.$week.'"
				and nota.intid_jpenjualan = 6 )intomset201free110prs,				
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang
				WHERE nota.intid_week = "'.$week.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_jpenjualan = 7) omsetnetto, 
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang
				WHERE nota.intid_week = "'.$week.'"
				AND nota.intid_cabang = c.intid_cabang
				AND  nota.intid_jpenjualan = 11) omsetspecialprice,
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang
				WHERE nota.intid_week = "'.$week.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_jpenjualan = 12) omsetpoint,
				(SELECT sum(nota.inttotal_bayar) 
				FROM nota
				WHERE nota.intid_week = "'.$week.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_jpenjualan = 10) omsetsk,
				(select sum(nota_detail.intquantity*nota_detail.intharga) 
				from nota, nota_detail, barang 
				where nota.intid_nota = nota_detail.intid_nota
				and nota_detail.intid_barang = barang.intid_barang
				and nota.intid_week = "'.$week.'"
				and nota.intid_cabang = c.intid_cabang
				and nota.is_arisan = 0
				and nota.is_dp = 0
				and barang.intid_jbarang=5) omsetlg,
				(select sum(nota_detail.intquantity*nota_detail.intharga) 
				from nota, nota_detail, barang 
				where nota.intid_nota = nota_detail.intid_nota
				and nota_detail.intid_barang = barang.intid_barang
				and nota.intid_week = "'.$week.'"
				and nota.intid_cabang = c.intid_cabang
				and barang.intid_jbarang=6
				and nota.is_arisan = 0
				and nota.is_dp = 0) omsetll,
				(select sum(inttotal_bayar) from nota where 
				nota.intid_cabang = c.intid_cabang
				and nota.intid_week = "'.$week.'") inttotal_bayar,
				(select sum(intpv) from nota where 
				nota.intid_cabang = c.intid_cabang
				and nota.is_dp = 0
				and nota.intid_week = "'.$week.'") intpv,
			c.strnama_cabang 
			from cabang c';
		$query = $this->db->query($this->temp);
	return $query->result();
		}
	/**
		*	@param Black_WoodPecker
		*	I:	intid_week,
		*	O:	query->result
		* 	Desc: untuk melihat laporan semua omset per-bulan dari seluruh cabang
		*/
		function Black_WoodPecker($month){
		//////isinya sma dengan sales Bulanan tapi semua cabang dimunculin.
		
		$this->temp = 'select
				(SELECT SUM(nota.inttotal_omset) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'") inttotal_omset,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.is_arisan != 1 
				and nota.intid_jpenjualan = 1 ) intomset10Reguler,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.is_arisan != 1 
				and nota.intid_jpenjualan = 1)intomset20Reguler,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.is_arisan = 1 
				and nota.intid_jpenjualan = 1 ) intomset10Arisan,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.is_arisan = 1 
				and nota.intid_jpenjualan = 1)intomset20Arisan,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 2 ) intomset10ChallHut,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.is_dp != 1 
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 2 )intomset20ChallHut,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.is_dp != 1 
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 3 ) intomset10Challange,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.is_dp != 1 
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 3 )intomset20Challange,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.is_dp != 1 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 4 ) intomset10TradeIn,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 4 )intomset20TradeIn,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE  nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'" 
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 5 ) intomset101free1net,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 5 )intomset201free1net,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 6 ) intomset101free110prs,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 6 )intomset201free110prs,				
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_cabang != 1
				and nota.is_dp != 1 
				AND nota.intid_jpenjualan = 7) omsetnetto, 
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_cabang != 1
				and nota.is_dp != 1 
				AND nota.intid_jpenjualan = 11) omsetspecialprice,
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				and nota.is_dp != 1 
				AND nota.intid_jpenjualan = 12) omsetpoint,
				(SELECT sum(nota.inttotal_bayar) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				and nota.is_dp != 1 
				AND nota.intid_jpenjualan = 10) omsetsk,
				(select sum(nota_detail.intquantity*nota_detail.intharga) 
				from nota, nota_detail, barang, week 
				where nota.intid_nota = nota_detail.intid_nota
				and nota_detail.intid_barang = barang.intid_barang
				and week.intbulan = "'.$month.'"
				and nota.intid_week = week.intid_week
				and nota.intid_cabang = c.intid_cabang
				and nota.is_arisan = 0
				and nota.is_dp = 0
				and barang.intid_jbarang=5) omsetlg,
				(select sum(nota_detail.intquantity*nota_detail.intharga) 
				from nota, nota_detail, barang, week 
				where nota.intid_nota = nota_detail.intid_nota
				and nota_detail.intid_barang = barang.intid_barang
				and week.intbulan = "'.$month.'"
				and nota.intid_week = week.intid_week
				and nota.intid_cabang = c.intid_cabang
				and barang.intid_jbarang=6
				and nota.is_arisan = 0
				and nota.is_dp = 0) omsetll,
				(select sum(inttotal_bayar) from nota inner join week on nota.intid_week = week.intid_week
				where 
				nota.intid_cabang = c.intid_cabang
				and nota.is_dp != 1 
				and week.intbulan = "'.$month.'") inttotal_bayar,
				(select sum(intpv) from nota inner join week on nota.intid_week = week.intid_week where 
				nota.intid_cabang = c.intid_cabang
				and nota.is_dp != 1 
				and week.intbulan = "'.$month.'") intpv,
			c.strnama_cabang 
			from cabang c';
			/*
			$this->temp = 'select
				(SELECT SUM(nota.inttotal_omset) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'") inttotal_omset,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.is_arisan != 1 
				and nota.intid_jpenjualan = 1 ) intomset10Reguler,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.is_arisan != 1 
				and nota.intid_jpenjualan = 1)intomset20Reguler,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.is_arisan = 1 
				and nota.intid_jpenjualan = 1 ) intomset10Arisan,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.is_arisan = 1 
				and nota.intid_jpenjualan = 1)intomset20Arisan,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 2 ) intomset10ChallHut,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.is_dp != 1 
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 2 )intomset20ChallHut,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.is_dp != 1 
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 3 ) intomset10Challange,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and nota.is_dp != 1 
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 3 )intomset20Challange,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.is_dp != 1 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.intid_jpenjualan = 4 ) intomset10TradeIn,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 4 )intomset20TradeIn,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE  nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'" 
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 5 ) intomset101free1net,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 5 )intomset201free1net,
				(SELECT SUM(nota.intomset10) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 5 
				AND nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 6 ) intomset101free110prs,
				(SELECT SUM(nota.intomset20) FROM nota inner join week on nota.intid_week = week.intid_week
				WHERE nota.intid_jpenjualan != 7 
				and nota.intid_cabang = c.intid_cabang  
				and week.intbulan = "'.$month.'"
				and nota.is_dp != 1 
				and nota.intid_jpenjualan = 6 )intomset201free110prs,				
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_cabang != 1
				and nota.is_dp != 1 
				AND nota.intid_jpenjualan = 7) omsetnetto, 
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				AND nota.intid_cabang != 1
				and nota.is_dp != 1 
				AND nota.intid_jpenjualan = 11) omsetspecialprice,
				(SELECT SUM(nota_detail.intquantity*nota_detail.intharga) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				and nota.is_dp != 1 
				AND nota.intid_jpenjualan = 12) omsetpoint,
				(SELECT sum(nota.inttotal_bayar) 
				FROM nota INNER JOIN nota_detail ON nota.intid_nota = nota_detail.intid_nota INNER JOIN barang ON nota_detail.intid_barang = barang.intid_barang INNER JOIN week on nota.intid_week = week.intid_week
				WHERE week.intbulan = "'.$month.'"
				AND nota.intid_cabang = c.intid_cabang
				and nota.is_dp != 1 
				AND nota.intid_jpenjualan = 10) omsetsk,
				(select sum(nota_detail.intquantity*nota_detail.intharga) 
				from nota, nota_detail, barang, week 
				where nota.intid_nota = nota_detail.intid_nota
				and nota_detail.intid_barang = barang.intid_barang
				and week.intbulan = "'.$month.'"
				and nota.intid_week = week.intid_week
				and nota.intid_cabang = c.intid_cabang
				and nota.is_arisan = 0
				and nota.is_dp = 0
				and barang.intid_jbarang=5) omsetlg,
				(select sum(nota_detail.intquantity*nota_detail.intharga) 
				from nota, nota_detail, barang, week 
				where nota.intid_nota = nota_detail.intid_nota
				and nota_detail.intid_barang = barang.intid_barang
				and week.intbulan = "'.$month.'"
				and nota.intid_week = week.intid_week
				and nota.intid_cabang = c.intid_cabang
				and barang.intid_jbarang=6
				and nota.is_arisan = 0
				and nota.is_dp = 0) omsetll,
				(select sum(inttotal_bayar) from nota inner join week on nota.intid_week = week.intid_week
				where 
				nota.intid_cabang = c.intid_cabang
				and nota.is_dp != 1 
				and week.intbulan = "'.$month.'") inttotal_bayar,
				(select sum(intpv) from nota inner join week on nota.intid_week = week.intid_week where 
				nota.intid_cabang = c.intid_cabang
				and nota.is_dp != 1 
				and week.intbulan = "'.$month.'") intpv,
			c.strnama_cabang 
			from cabang c';
			*/
		$query = $this->db->query($this->temp);
	return $query->result();
		}
		/**
		*/
		function owl($kode,$week)
			{
				//$week = $this->db->query("select intid_week from week where curdate() between dateweek_start and dateweek_end");
				//$id_week = $week->result();
				//$week_now = $id_week[0]->intid_week;
				$query = $this->db->query("select distinct(a.datetgl) tanggal, a.intno_nota,a.inttotal_omset 
										   from nota a join nota_detail b on a.intid_nota=b.intid_nota 
										   where a.intid_dealer = $kode
										   and a.intid_week = $week
										   and a.is_lg = 0
										   and a.is_dp = 0");
				return $query->result();
			}
			
			function show_temp(){
				$query = $this->db->query('select intid_cabang from cabang ');
				return $query->result();
			}
			/**
		*	@param Golden_Eagle, 
		*	I:	intid_jpenjualan, intbulan, intbulan
		*	O:	query->result
		* 	Desc: penggunaan untuk menampilkan data penjualan setiap unit yang terdaftar di tabel, dengan patokan intid_jpenjualan
		*/
		function Golden_Eagle($jenisPenjualan,$bulanPertama,$bulanKedua){
				//lakukan pencarian
				$var = "";
				if($jenisPenjualan == 1){
					$var = "select sum(nota.inttotal_omset) 
								from nota 
								where (nota.intid_jpenjualan = 1 or nota.intid_jpenjualan = 9) 
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 2){
						$var = "select sum(nota.inttotal_omset) 
								from nota 
								where nota.intid_jpenjualan = 2 
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 3){
						$var = "select sum(nota.inttotal_omset) 
								from nota 
								where nota.intid_jpenjualan = 3 
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 4){
						$var = "select sum(nota.inttotal_omset) 
								from nota 
								where nota.intid_jpenjualan = 4 
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 5){
						$var = "select sum(nota.inttotal_omset) 
								from nota 
								where nota.intid_jpenjualan = 5 
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 6){
						$var = "select sum(nota.inttotal_omset) 
								from nota 
								where nota.intid_jpenjualan = 6 
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 7){
						$var = "select sum(nota.inttotal_omset) 
								from nota 
								where nota.intid_jpenjualan = 7 
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 8){
						$var = "select sum(nota.inttotal_bayar) 
								from nota 
								where nota.intid_jpenjualan = 7 
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 9){
						$var = "select sum(nota.inttotal_omset) 
								from nota 
								where (nota.intid_jpenjualan = 9 or nota.intid_jpenjualan = 1) 
								and nota.is_arisan = 1
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 10){
						$var = "select sum(nota.inttotal_bayar) 
								from nota 
								where nota.intid_jpenjualan = 10 
								and nota.is_arisan = 1
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 11){
						$var = "select sum(nota.inttotal_bayar) 
								from nota 
								where nota.intid_jpenjualan = 11
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 12){
						$var = "select sum(nota.inttotal_bayar) 
								from nota 
								where nota.intid_jpenjualan = 12
								and nota.is_dp = 0";
					}elseif($jenisPenjualan == 13){
						$var = "select sum(nota.inttotal_bayar) 
								from nota 
								where nota.intid_jpenjualan = 13
								and nota.is_dp = 0";
					}
				//semua dijadikan satu string baru di eksekusi	
				$this->temp = "select strnama_unit,
				(select strnama_dealer 
				 	from member 
					where member.intid_unit = unit.intid_unit
					and intlevel_dealer = 1
					and intparent_leveldealer = 0
					group by strkode_dealer) nama_manager, 
				(".$var." 
				 	and nota.intid_unit = unit.intid_unit
					and nota.intid_week in (select intid_week 
												from week where intbulan >= '".$bulanPertama."' and intbulan <= '".$bulanKedua."')) total_penjualan,
				(select strnama_jpenjualan 
				 from jenis_penjualan 
				 where intid_jpenjualan = ".$jenisPenjualan.") strnama_jpenjualan
				from unit";
				$query = $this->db->query($this->temp);
				return $query->result();
			}
	}
?>